//
//  main.swift
//  Facade
//
//  Created by LY on 2017/11/1.
//  Copyright © 2017年 DesignPatterns. All rights reserved.
//

import Foundation

let map = TreasureMap()
let ship = PirateShip()
let crew = PirateCrew()

let treasureLocation = map.findTreasure(type: .GALLEON)

let sequeue : [Character] = ["A","B","C","D","E","F","G"]

let eastWestPos = sequeue.index(of: treasureLocation.gridLetter)

let shipTarget = PirateShip.ShipLocation(NorthSouth: Int(treasureLocation.gridNumber), EastWest: eastWestPos!)

ship.moveToLocation(location: shipTarget) { (location) in
    crew.preformAction(action: .ATTACK_SHIP, callback: { (price) in
        print("Prize:\(price) pieces of eight")
    })
}
//_ = FileHandle.standardInput.availableData

let privateFacade = PirateFacade()
let prize = privateFacade.getTreasure(type: .SHIP)
if (prize != nil){
    print("隐藏实现的实现方式 prize : \(String(describing:prize! ))")
}

let transparentFacade = TransparentFacade()
let transparenPrize = transparentFacade.getTreasure(type: .SHIP)
if(transparenPrize != nil){
    print("透明实现的实现方式 prize : \(String(describing:transparenPrize!))")
}


